package com.rainng.coursesystem.controller.admin;

import com.rainng.coursesystem.controller.BaseController;
import com.rainng.coursesystem.controller.admin.vo.VisBatchEntityVo;
import com.rainng.coursesystem.model.entity.VisBatchEntity;
import com.rainng.coursesystem.model.shitong.*;
import com.rainng.coursesystem.model.vo.response.ResultVO;
import com.rainng.coursesystem.module.task.service.BatchService;
import com.rainng.coursesystem.service.DeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Api(tags = "设备接口")
@RequestMapping("/admin/v2/device")
@RestController
@Slf4j
public class DeviceController extends BaseController {

    @Resource
    private DeviceService deviceService;

    //tire/page
    @PostMapping("/page")
    @ApiOperation(value = "分页查询")
    public ResultVO pageDeviceQuery(@RequestBody DeviceVo vo){
        return deviceService.queryDevice(vo);
    }

    @PostMapping("/page/count")
    @ApiOperation(value = "分页查询数量")
    public ResultVO pageDeviceCount(@RequestBody DeviceVo vo){
        return deviceService.countDevice(vo);
    }

    @PostMapping("/save")
    @ApiOperation(value = "存储")
    public ResultVO saveDevice(@RequestBody DeviceSaveVo vo){
        return deviceService.saveDevice(vo);
    }

    @GetMapping("/delete/{id}")
    @ApiOperation(value = "删除")
    public ResultVO deleteDevice(@PathVariable String id){
        return deviceService.deleteDevice(id);
    }

    @PostMapping("/update/{id}")
    @ApiOperation(value = "编辑")
    public ResultVO updateDevice(@PathVariable String id,@RequestBody DeviceSaveVo vo){
        return deviceService.updateDevice(id,vo);
    }

    @PostMapping("/update/state/{id}")
    @ApiOperation(value = "编辑状态")
    public ResultVO updateStateDevice(@PathVariable String id, @RequestBody DeviceStateUpdateVo vo){
        return deviceService.updateStateDevice(id,vo);
    }

    @PostMapping("/update/validtime/{id}")
    @ApiOperation(value = "编辑有效时间")
    public ResultVO updateValidTimeDevice(@PathVariable String id, @RequestBody DeviceValidTimeUpdateVo vo){
        return deviceService.updateValidDevice(id,vo);
    }


    @PostMapping("/logs/page")
    @ApiOperation(value = "日志分页查询")
    public ResultVO pageDeviceLogsQuery(@RequestBody DeviceLogsVo vo){
        return deviceService.queryLogsDevice(vo);
    }

    @PostMapping("/logs/page/count")
    @ApiOperation(value = "分页查询数量")
    public ResultVO pageDeviceLogsCount(@RequestBody DeviceLogsVo vo){
        return deviceService.countLogsDevice(vo);
    }




    @PostMapping("/time/logs/page")
    @ApiOperation(value = "日志分页查询")
    public ResultVO pageDeviceTimeLogsQuery(@RequestBody DeviceLogsVo vo){
        return deviceService.queryTimeLogsDevice(vo);
    }

    @PostMapping("/time/logs/page/count")
    @ApiOperation(value = "分页查询数量")
    public ResultVO pageDeviceTimeLogsCount(@RequestBody DeviceLogsVo vo){
        return deviceService.countTimeLogsDevice(vo);
    }

    @PostMapping("/deviceQueryByParams")
    @ApiOperation(value = "条件查询试验设备")
    public ResultVO deviceQueryByParams(@RequestBody Map<String, List<String>> req){
        return deviceService.deviceQueryByParams(req.get("prjNames"), req.get("measureRequirement"));
    }



//    @GetMapping("/refresh/status")
//    @ApiOperation(value = "刷新状态")
//    public void refreshDevices(){
//        deviceService.refreshStatus();
//    }

//
//    @GetMapping("/test")
//    public void test(){
//        deviceService.insertDeviceLogs("aaa","bbbb",null);
//    }


}
